<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<!-- remove old header -->


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>cogen API Reference Documentation
        - Class: SendFile</title><meta name="MSSmartTagsPreventParsing" content="true" /><meta http-equiv="imagetoolbar" content="no" /><link href="css/default.css" rel="stylesheet" type="text/css" /><link href="css/pygments.css" rel="stylesheet" type="text/css" />
    <!-- <link rel="shortcut icon" href="/images/favicon.ico" type="image/vnd.microsoft.icon"/> -->
    <link rel="stylesheet" href="css/apydia.css" type="text/css" />
    <script src="js/jquery-1.2.1.pack.js" type="text/javascript"></script>
    <script src="js/apydia.js" type="text/javascript"></script>
	<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
</head>
<body>
    <div id="page">
        <div id="browser">
            <div class="browser-section">
                <h2>Module Index</h2>
                <ul>
                    <li>
                        <a href="cogen.html">cogen</a>
                    </li><li>
                        <a href="cogen.common.html">cogen.common</a>
                    </li><li>
                        <a href="cogen.core.html">cogen.core</a>
                    </li><li>
                        <a href="cogen.web.html">cogen.web</a>
                    </li>
                </ul>
            </div>
            <div class="browser-section">
                <h2>Methods</h2>
                <ul>
                    <li>
                        <a href="cogen.core.sockets.SendFile.html#method-__init__">__init__</a>
                    </li><li>
                        <a href="cogen.core.sockets.SendFile.html#method-run">run</a>
                    </li>
                </ul>
            </div>
        </div>
        <div id="content">
    <h1>Class: cogen.core.sockets.SendFile</h1>
    <div class="docstring rst"><p>Uses underling OS sendfile call or a regular memory copy operation if
there is no sendfile.
You can use this as a WriteAll if you specify the length.
Usage:</p>
<div class="source"><pre><span class="k">yield</span> <span class="n">sockets</span><span class="o">.</span><span class="n">SendFile</span><span class="p">(</span><span class="o">&lt;</span><span class="nb">file</span> <span class="n">handle</span><span class="o">&gt;</span><span class="p">,</span> <span class="o">&lt;</span><span class="n">sock</span><span class="o">&gt;</span><span class="p">,</span> <span class="mf">0</span><span class="p">)</span>
    <span class="c"># will send till send operations return 0</span>

<span class="k">yield</span> <span class="n">sockets</span><span class="o">.</span><span class="n">SendFile</span><span class="p">(</span><span class="o">&lt;</span><span class="nb">file</span> <span class="n">handle</span><span class="o">&gt;</span><span class="p">,</span> <span class="o">&lt;</span><span class="n">sock</span><span class="o">&gt;</span><span class="p">,</span> <span class="mf">0</span><span class="p">,</span> <span class="n">blocksize</span><span class="o">=</span><span class="mf">0</span><span class="p">)</span>
    <span class="c"># there will be only one send operation (if successfull)</span>
    <span class="c"># that meas the whole file will be read in memory if there is</span>
    <span class="c">#no sendfile</span>

<span class="k">yield</span> <span class="n">sockets</span><span class="o">.</span><span class="n">SendFile</span><span class="p">(</span><span class="o">&lt;</span><span class="nb">file</span> <span class="n">handle</span><span class="o">&gt;</span><span class="p">,</span> <span class="o">&lt;</span><span class="n">sock</span><span class="o">&gt;</span><span class="p">,</span> <span class="mf">0</span><span class="p">,</span> <span class="o">&lt;</span><span class="nb">file</span> <span class="n">size</span><span class="o">&gt;</span><span class="p">)</span>
    <span class="c"># this will hang if we can'self read &lt;file size&gt; bytes</span>
    <span class="c">#from the file</span>
</pre></div>
</div>
    <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\core\sockets.py#L115">View source</a>
    </li>
</ul>
    <div>
        <h2>Methods</h2>
            <h3 id="method-__init__">
                __init__
                <span class="args">(self, file_handle, sock, offset=None, length=None, blocksize=4096, **kws)</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\core\sockets.py#L142">View source</a>
    </li>
</ul>
            <h3 id="method-run">
                run
                <span class="args">(self)</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="top"><a href="#header">Top</a></li>
    <li class="link-to-sourcecode">
        <a href="http://cogen.googlecode.com/svn/trunk/cogen\cogen\core\sockets.py#L161">View source</a>
    </li>
</ul>
    </div>
        </div>
        <div id="footer">
            Generated with <a href="http://apydia.ematia.de/" class="extern">
            Apydia 0.0.2</a>
        </div>
    </div>
</body>
</html>